package com.qys.livesMall.app.user.model.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/04/20
 * Time: 17:53
 * DESCRIPTION: 用户类型
 */
@Getter
@AllArgsConstructor
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum UserTypeEnum {

    REGULAR_USERS("普通用户", 0),
    STORE("店主", 1),
    ANCHOR("主播", 2),
    STORE_AND_ANCHOR("店主加主播", 3),
    ;

    private String name;
    private Integer code;

    public static UserTypeEnum getEnum(Integer code) {
        for (UserTypeEnum typeEnum : UserTypeEnum.values()) {
            if (Objects.equals(typeEnum.getCode(), code)) {
                return typeEnum;
            }
        }
        return null;
    }
}
